create table dcUser (
	dcUserId smallint unsigned not null auto_increment primary key,
	login varchar(255) not null default "",
	index (login),
	password varchar(255) not null default "",
	fullName varchar(310) not null default ""
	);

create table userEmail (
	dcUserId smallint unsigned not null,
	index (dcUserId),
	foreign key (dcUserId) references dcUser(dcUserId),
	userEmail varchar(255)
	);

create table dcRole (
	dcRoleId smallint unsigned not null auto_increment primary key,
	roleName varchar(255) not null default ""
	);
	
create table roleToUser (
	dcRoleId smallint unsigned not null,
	index (dcRoleId),
	foreign key (dcRoleId) references dcRole(dcRoleId),
	dcUserId smallint unsigned not null,
	index (dcUserId),
	foreign key (dcUserId) references dcUser(dcUserId)
	);

insert into dcRole values( default, "Administrators");
set @adminRole = last_insert_id();

insert into dcUser values (default, "DocCircAdmin", PASSWORD("1"), "DocCirc Administrator");
insert into userEmail values (last_insert_id(), "doccircadmin@debug.org");
insert into roleToUser values (@adminRole, last_insert_id());

insert into dcUser values (default, "DocCircService", PASSWORD("1"), "DocCirc service user");
insert into userEmail values (last_insert_id(), "doccircservice@debug.org");
insert into roleToUser values (@adminRole, last_insert_id());

